/**
 * Created by kongwentao on 2017/5/26.
 */

var URL = "https://api.waqi.info/feed/geo:39.897778;116.414898/?token=50ec8be96a1741835fa6b417c5a76ae801fb87d4"
const BASE_URL = "http://api.waqi.info/feed/geo:"
const TOKEN = "50ec8be96a1741835fa6b417c5a76ae801fb87d4"

import Vue from 'vue'
import VueResource from 'vue-resource'
Vue.use(VueResource)
var vue = new Vue();

export default {
    getExponent:function (lngLat,cb) {
        console.log("api....")
        var requestUrl =  `${BASE_URL}${lngLat.lat};${lngLat.lng}/?token=${TOKEN}`
        console.log(requestUrl)
        vue.$http.get(requestUrl).then((response) => {
            console.log("AQI responsed:")
            console.log(response.data)
            cb(eval(response.data.data));
        }, (response) => {
            console.log(response.json());
        });
    }
}